package com.network.util;

import com.lmax.disruptor.RingBuffer;
import com.network.entity.FileSave;

/**
 * 消息生产者
 */
public class Producer
{
    private final RingBuffer<FileSave> ringBuffer;

    public Producer(RingBuffer<FileSave> ringBuffer) {
        this.ringBuffer = ringBuffer;
    }

    public void puthData(FileSave file)
    {
        long sequence= ringBuffer.next();
        try
        {
            FileSave fileSave= ringBuffer.get(sequence);
            fileSave.setFileSave(file);

        }catch (Exception e)
        {
            e.printStackTrace();
        }finally {
            ringBuffer.publish(sequence);
        }

    }
}
